function IsPC() {
    var userAgentInfo = navigator.userAgent;
    var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
    var flag = true;
    for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
            flag = false;
            break
        }
    }
    return flag
}

const userEqt = IsPC() ? 1 : 0
console.log(userEqt)
let nowUrl = window.location.href;
let nowIp = returnCitySN["cip"];
layui.use(['layer', 'form'], function () {
    var layer = layui.layer, form = layui.form;
    form.render();
    form.verify({
        username: val => {
            if (val.length > 1000) {
                return "请输入正确的姓名"
            }
        }, address: value => {
            if (value.length > 1000) {
                return "请输入正确的地区"
            }
        }
    });
    form.on('submit(go)', data => {
        var goForm = data.field;
        let {username, phone, address} = goForm;
        console.log(username)
        console.log(phone)
        console.log(address)
        console.log(nowIp);
        axios.post("http://www.zhou-yuanwai.com/leave/insert.do?name=" + username + "&url=" + nowUrl + "&tell=" + phone + "&category=1&ip=" + nowIp + "&description=1" + address + "&hasComputer=" + userEqt).then(res => {
            console.log(res);
            if (res.data) {
                layer.msg("发送成功，我们会尽快与您联系")
            }
            let inps = document.querySelectorAll("input");
            inps.forEach(item => {
                item.value = ""
            })
        }).catch(err => {
            layer.msg("错误，请再次提交")
        });
        return false
    })
});
